<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<div class="modal fade" id="sysuser_edit_modal" tabindex="1000" role="dialog" aria-labelledby="addModalLabel" aria-hidden="true"> 
	<div class="modal-dialog" style="width:30%;"> 
		<div class="modal-content">
			<div class="modal-header">
				<h4 class="modal-title mt5">编辑用户信息
					<a style="float:right" id="close_modal" data-dismiss="modal">
						<span style="font-size:16px;" class="glyphicon glyphicon-remove"></span>
					</a>
				</h4>
			</div>
			<div class="modal-body" id="sysuser_modal_body" style="overflow: auto;">
				<form role="form" id="sysuser_form">
	              <div class="box-body">
	                <div class="form-group">
	                  <label for="name">姓名</label>
	                  <input type="text" class="form-control" name="name" id="name" placeholder="姓名">
	                </div>
	                <div class="form-group">
	                  <label for="phone">手机号</label>
	                  <input type="text" class="form-control" name="phone" id="phone" placeholder="手机号">
	                </div>
	                <div class="form-group">
	                  <label for="logname">登录名</label>
	                  <input type="text" class="form-control" name="logname" id="logname" placeholder="登录名">
	                </div>
	                <div class="form-group">
	                  <label for="pwd">登录密码</label>
	                  <input type="password" class="form-control" name="pwd" id="pwd" placeholder="登录密码">
	                </div>
	                <div class="form-group">
	                  <label for="input_file">上传文件</label>
	                 <!--  <input type="file" id="input_file">
	                  <button type="button" class="btn btn-info btn-flat">确定上传</button> -->
	                  <div class="input-group input-group-sm">
		                <input type="file" id="input_file">
		                    <span class="input-group-btn">
		                      <button type="button" id="btn_input_file" class="btn btn-info btn-flat">确定上传</button>
		                    </span>
		              </div>
	                  <p class="help-block">请选择office文件</p>
	                </div>
	               
	              </div>
	              <!-- /.box-body -->
	            </form>
			
			</div>
			<div class="modal-footer">
				<button id="btn_save" type="button"  class="btn btn-info ml5">保存</button>
				<button id="btn_return" type="button" data-dismiss="modal" class="btn btn-info ml5">返回</button>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
(function(){
	$(function(){
		
	});
	$("#input_file").change(function() {
		var file=this.files[0];
		var fileName=file.name;
		var arr=fileName.split(".");
		var endName=arr[arr.length-1];
		var formData = new FormData();
		formData.append("file",file);
		formData.append("field","文件");
		formData.append("value","");
		formData.append("table_id","roottest");
		$(this).data("fileData",formData);
	})
	$("#btn_input_file").on("click",function(){
		$.ajax({
            url: '${pageContext.request.contextPath}/uploadSysuserFile',
            type: "POST",
            data: $("#input_file").data("fileData"),
            processData: false,  
            contentType: false,  
            success: function (res) {
            	var json=JSON.parse(res);
                console.log(json);
            }
        });
	})
	$("#close_modal").on("click",function(){
		$("#sysuser_edit_modal").modal('hide').remove();
		$('.modal-backdrop').remove();
	});
	$("#btn_return").on("click",function(){
		$("#sysuser_edit_modal").modal('hide').remove();
		$('.modal-backdrop').remove();
	});
	$("#btn_save").on("click",function(){
		var t = $("#sysuser_form").serializeArray();
		var data = {};
          debugger 
        $.each(t, function() {
        	data [this.name] = this.value;
        });

		$.ajax({
			url:"${pageContext.request.contextPath}/reguser",
			type:"post",
			data:data,
			success:function(res){
				var json=JSON.parse(res);
                console.log(json);
                //关闭模态框
                $("#sysuser_edit_modal").modal('hide').remove();
        		$('.modal-backdrop').remove();
			}
		})
	})
})()
</script>